/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package Review.test4.waitNotify;

import java.util.logging.Level;
import java.util.logging.Logger;

/**
 *
 * @author THIEN
 */
public class ThreadTwo extends MyThread{

    public ThreadTwo(Data d) {
        super(d);
    }

    @Override
    public void run(){
        this.displayArr();
    }
    public void displayArr(){
        for(int i = 0;i<5;i++){
            synchronized(this.d){
                if(d.flag){
                    System.out.println(d.temp);
                    d.flag = false;
                    d.notify();
                }
                try {
                    d.wait();
                } catch (InterruptedException ex) {
                    //Logger.getLogger(ThreadTwo.class.getName()).log(Level.SEVERE, null, ex);
                }
            }
        }
    }

}
